package com.dlsy.ygj.dao.vindicateData.impl;

import com.dlsy.ygj.dao.vindicateData.IStorefrontDAO;
import com.dlsy.ygj.entity.Storefront;

import java.sql.SQLException;
import java.util.List;

import net.taobaoge.common.framework.dao.impl.BaseDAOImpl;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.HibernateException;
import org.hibernate.LockMode;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.criterion.Example;
import org.springframework.orm.hibernate3.HibernateCallback;

/**
 * A data access object (DAO) providing persistence and search support for
 * Storefront entities. Transaction control of the save(), update() and delete()
 * operations can directly support Spring container-managed transactions or they
 * can be augmented to handle user-managed Spring transactions. Each of these
 * methods provides additional information for how to configure it for the
 * desired type of transaction control.
 * 
 * @see com.dlsy.ygj.entity.Storefront
 * @author MyEclipse Persistence Tools
 */

public class StorefrontDAO extends BaseDAOImpl<Storefront> implements IStorefrontDAO {
	
	@SuppressWarnings("unchecked")
	public List<Storefront> searchStorefrontByKeyword(final String keyword) {
		return getHibernateTemplate().executeFind(new HibernateCallback() {
			public Object doInHibernate(Session session)
					throws HibernateException, SQLException {
				Query query = session.createQuery("From Storefront s where s.storefromName like ? or s.shortName like ? or s.storeName like ?");
				query.setString(0, "%" + keyword + "%");
				query.setString(1, "%" + keyword + "%");
				query.setString(2, "%" + keyword + "%");
				List<Storefront> list = query.list();
				return list;
			}
		});
	}
}